#include "iap_update_app_hardware.h"
#include "Global.h"
#include "gpio.h"
#include "iap_sci.h"


void update_app_hardware_config(void)
{
	//TX
//	PORT_Init(UPDATE_AP_TX_IOPORT,UPDATE_AP_TX_PIN,OUTPUT);
//	UPDATE_AP_TX_SET_HIGH();
//	PORT_Output_Cfg(UPDATE_AP_TX_CFG,UPDATE_AP_IOCFG_COMX);
//  
  PORT->P70CFG = 0x06;        /* allocate TXD1 to P00 */ \
  PORT->P7   |=  (1 << 0);    /* P00 output high level */ \
  PORT->PM7  &= ~(1 << 0);    /* P00 is used as TXD1 output */ \
  PORT->POM7 &= ~(1 << 0);    /* P00 is normal output mode */ \
  PORT->PMC7 &= ~(1 << 0);    /* P00 digital function */ \
  

	//RX
//	PORT_Init(UPDATE_AP_RX_IOPORT,UPDATE_AP_RX_PIN,INPUT);
//	PORT_Input_Cfg(UPDATE_AP_RX_CFG,UPDATE_AP_RX_COMX_CFG);
  
  PORT->RXD2PCFG = PORTINPUT_CFG_P71;      /* allocate RXD1 to P01 */ \
  PORT->PM7  |=  (1 << 1);    /* P01 is used as RXD1 input */ \
  PORT->PMC7 &= ~(1 << 1);    /* P01 digital function */ \

	UART2_Init(SystemCoreClock,UPDATE_AP_BaudRate);
//	INTC_ClearPendingIRQ(SR0_IRQn); /* clear INTSR0 interrupt flag */
//	INTC_EnableIRQ(SR0_IRQn);		/* enable INTSR0 interrupt */
}


